home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / gfx / 3d / IIB10.lha / IIB / Threads / Point_Replace_Script < prev    next >
Encoding:
Text File  |  1998-03-08  |  11.4 KB  |  383 lines

  1. The original question was a proposal to include a function in imagine to
  2. replace all points of an object with another object:
  3.  
  4. Date:         Sun, 11 Jan 1998 14:34:17 -0500
  5. From: Richard Mattsson <richard@CLOUDNET.COM>
  6.  
  7. On further investigation, my test with the '4/4 section' primitive
  8. sphere as a template for the ARexx point replacement seems to indicate
  9. it behaves differently if the Detail editor is in Group mode or in
  10. Object mode when a copy of the sphere object is pasted.
  11.  
  12. (This sphere had been scaled up from the default size. I decided to try
  13. an unscaled object, and discovered a different result, also!)
  14.  
  15. Indicating which points appear to be correctly read (and used to
  16. position the newobject):
  17.  
  18.                 Object Mode  Group Mode    Both Modes
  19.                 (scaled up)  (scaled up)  (not scaled)
  20.  
  21.  
  22. POINT                 X          X             X
  23. POINT.1               X          X             X
  24. POINT.2               X          X             X
  25. POINT.3               X          X             X
  26. POINT.4               X          X             X
  27. POINT.5
  28. POINT.6                          X             X
  29. POINT.7                                        X
  30. POINT.8               X          X             X
  31. POINT.9               X          X             X
  32. POINT.10              X          X             X
  33. POINT.11              X          X             X
  34. POINT.12              X          X             X
  35. POINT.13
  36.  
  37. I wonder if it's an obscure 'feature' in the GETGEOMETRY command?
  38.  
  39. Is there a way to directly read the variables written by the GETGEOMETRY
  40. command?
  41.  
  42. ---------------------------------
  43.  
  44. Date:         Sun, 11 Jan 1998 18:38:39 -0500
  45. From: "Ash R. J. Wyllie" <ashw@LR.NET>
  46.  
  47. There seems to be a problem with transform. It seems that too many digits to
  48. the right of the decimal point screws things up. Try using trunc(var,4).
  49.  
  50. ---------------------------------
  51.  
  52. Date:         Sat, 10 Jan 1998 22:20:19 -0500
  53. Ash R. J. Wyllie <ashw@LR.NET> wrote:
  54.  
  55. >     getgeometry
  56. >     delete  /* I assume that you don't need the object anymore...*/
  57. >     do i=1 to PNT_NUM
  58. >        loadobject "whatever" /* I didn't see copy/paste */"
  59. >        pick select
  60. >        transform_translate PNT_Xi PNT_Y.i PNT_Z.i
  61. >     end
  62.  
  63. Okay, I got a chance to play a little. Caught the 'PNT_Xi' typo...
  64. (should be 'PNT_X.i' of course.)
  65.  
  66. Thanks! This might be pretty useful for a 'particle object generator'
  67. for those situations where there are subgroups, etc.
  68.  
  69. However, try this:
  70.  
  71. As my first test object, I used a primitive sphere with 4 circle
  72. sections and 4 vertical sections (14 points.)
  73.  
  74. For some reason, the GETGEOMETRY command doesn't seem to work on all the
  75. points. I get the first 5 OK, then several which don't work, and then a
  76. couple more which work, and then the last few fail as well (I think.)
  77.  
  78. Any ideas?
  79.  
  80. Otherwise, this looks like fun.
  81.  
  82. (Wait, I just re-tried this, and all but *one* of the points received a
  83. replacement object correctly... strange. BTW, I commented out the
  84. 'delete' line so I could verify the operation.)
  85.  
  86. --------------------------------
  87.  
  88. Date:         Sun, 11 Jan 1998 15:14:37 -0500
  89. From: "Ash R. J. Wyllie" <ashw@LR.NET>
  90.  
  91. At first glance, I thought it was negative numbers. Then maybe transform
  92. wouldn't translate beyond an earlier operation. What seems to be working now
  93. is to use *trunc(PNT_?,4)*. Not as bad as I thought earlier but still a bug.
  94.  
  95.  
  96. ---------------------------------
  97.  
  98. Date:         Sun, 11 Jan 1998 13:20:39 -0500
  99. From: "Ash R. J. Wyllie" <ashw@LR.NET>
  100.  
  101. I cleaned the script up a bit and generalized it a bit.
  102.  
  103. --
  104. /* addobj.irx  */
  105.  
  106. address "Imagine.1"
  107.  
  108. /* from screwthread.irx */
  109. IF ~EXISTS('LIBS:rexxreqtools.library') THEN DO
  110.    NOTIFY 'Please install the rexxreqtools.library in your LIBS: directory'
  111.    NOTIFY 'It is available from /pub/aminet/util/rexx/RexxReqTools.lha'
  112.    exit
  113. END
  114. CALL ADDLIB('rexxreqtools.library',0,-30,0)
  115.  
  116. PNT_NUM = 0
  117. getgeometry
  118. getaxisinfo
  119. if PNT_NUM = 0 then exit
  120. rid = rtezrequest("Keep your object?","Yes|No",,'rt_pubscrname = "Imagine"')
  121.  
  122. if rid = "No" then delete
  123.  
  124. newobj = rtfilerequest(,,"Object to Add",,'rt_pubscrname = "Imagine"',maybe)
  125. if ~maybe then exit
  126. address command 'copy 'newobj' to ram:obj'
  127.  
  128. displayrexxptr on
  129.  
  130. addaxis
  131. pick select
  132. getattributes
  133. axisName = ATTRIB.OBJECTNAME
  134.  
  135. transform_translate AXIS_POSITION_X  AXIS_POSITION_Y  AXIS_POSITION_Z
  136. transform_alignment AXIS_ALIGNMENT_X AXIS_ALIGNMENT_Y AXIS_ALIGNMENT_Z
  137.  
  138. do i=1 to PNT_NUM
  139.  
  140.   loadobject "ram:obj"
  141.   pick select
  142.   address command 'wait sec 1'
  143.  
  144.   say PNT_X.i PNT_Y.i PNT_Z.i /* for some reason transform translate */
  145.  
  146.                               /* does not like negative numbers      */
  147.   transform_translate PNT_X.i PNT_Y.i PNT_Z.i
  148.  
  149.   getattributes
  150.   unpick
  151.   multipickon
  152.   pick axisName
  153.   pick ATTRIB.OBJECTNAME
  154.   multipickoff
  155.   group
  156.  
  157. end
  158.  
  159. address command 'delete ram:obj quiet'
  160.  
  161. displayrexxptr off
  162.  
  163. exit
  164.  
  165. --
  166. transform translate does not like negative numbers at the moment. A bug?
  167.  
  168. ---------------------------------
  169.  
  170. Date:         Mon, 12 Jan 1998 09:13:32 -0500
  171. From: Richard Mattsson <richard@CLOUDNET.COM>
  172.  
  173. Ash R. J. Wyllie <ashw@LR.NET> wrote:
  174.  
  175. > I cleaned the script up a bit and generalized it a bit.
  176.  
  177. Hey, this looks slick!
  178.  
  179. Thanks, I'll try this out right away! (As long as work doesn't come in!)
  180.  
  181. > transform translate does not like negative numbers at the moment. A
  182. > bug?
  183.  
  184. Hmmm... I guess the position of the 'template' object needs to be in the
  185. positive 'octant' of 3D space, then.
  186.  
  187. And later:
  188.  
  189. >> For some reason, the GETGEOMETRY command doesn't seem to work on all
  190. >> the points. I get the first 5 OK, then several which don't work,
  191.  
  192. > At first glance, I thought it was negative numbers. Then maybe
  193. > transform wouldn't translate beyond an earlier operation. What seems
  194. > to be working now is to use *trunc(PNT_?,4)*. Not as bad as I thought
  195. > earlier but still a bug.
  196.  
  197. Pardon me, (maybe I'm dense...) where do you use 'trunc(PNT_?,4)'?
  198. (Oops, or are the '*' characters supposed to be included as well, not
  199. just for emphasis in your post?
  200. Thanks again! Good job. I nominate this for inclusion on some of the
  201. ARexx script pages out there...
  202.  
  203. ---------------------------------
  204.  
  205. Date:         Mon, 12 Jan 1998 18:16:33 -0500
  206. From: "Ash R. J. Wyllie" <ashw@LR.NET>
  207.  
  208.   *transform_translate trunc(PNT_X.i) trunc(PNT_Y.i) trunc(PNT_Z.i)*
  209.  
  210. I changed it in my im50/rexx drawer, and forgot that others hadn't seen what I
  211. was running. When programming I tend to get confused over trees and forests.
  212.  
  213. The transform_#? commands seem to have a problem. Relative commands (like
  214. rotate) don't work very well.
  215.  
  216. I just found a bug :). Change the 'translate' parts to 'position'. To the
  217. extent that translate works it is because the objects are being loaded at
  218. 0,0,0. Moving an object x,y,z units becomes the same as putting the object at
  219. x,y,z.
  220.  
  221. ---------------------------------
  222.  
  223. Date:         Tue, 13 Jan 1998 10:36:49 -0500
  224. From: Richard Mattsson <richard@CLOUDNET.COM>
  225.  
  226. Hey! It works! It works! :-)
  227.  
  228. This is really cool! Thanks so much, Ash! (Is the 'trunc' statement a
  229. general ARexx modifier? Just goes to show how little I'd have been able
  230. to do in this regard myself...)
  231.  
  232. It works! (Too bad *I* have to get to work this morning... the money
  233. kind, I mean!)
  234.  
  235. > The transform_#? commands seem to have a problem. Relative commands
  236. > (like rotate) don't work very well.
  237.  
  238. Hmm... interesting. So 'absolute' commands (like alignment) tend to work
  239. better? Good to keep in mind for future scripts.
  240.  
  241. > I just found a bug :). Change the 'translate' parts to 'position'. To
  242. > the extent that translate works it is because the objects are being
  243. > loaded at 0,0,0. Moving an object x,y,z units becomes the same as
  244. > putting the object at x,y,z.
  245.  
  246. Aha! That explains what happened when I used an object which had been
  247. 'snapshotted'! (Everything was offset...)
  248.  
  249. I hope someone else is as excited by this as I am. I'll post the
  250. complete script here (with the changes we discussed) so you can see what
  251. I understand from your posts, and so that others can use the script now
  252. 'as is'.
  253.  
  254. Thanks again! Good job!
  255.  
  256. --- CUT ---
  257. /* addobj.irx  */
  258.  
  259. address "Imagine.1"
  260.  
  261. /* from screwthread.irx */
  262. IF ~EXISTS('LIBS:rexxreqtools.library') THEN DO
  263.    NOTIFY 'Please install the rexxreqtools.library in your LIBS:
  264. directory'
  265.    NOTIFY 'It is available from /pub/aminet/util/rexx/RexxReqTools.lha'
  266.    exit
  267. END
  268. CALL ADDLIB('rexxreqtools.library',0,-30,0)
  269.  
  270. PNT_NUM = 0
  271. getgeometry
  272. getaxisinfo
  273. if PNT_NUM = 0 then exit
  274. rid = rtezrequest("Keep your object?","Yes|No",,'rt_pubscrname =
  275. "Imagine"')
  276.  
  277.  
  278. if rid = "No" then delete
  279.  
  280. newobj = rtfilerequest(,,"Object to Add",,'rt_pubscrname =
  281. "Imagine"',maybe)
  282. if ~maybe then exit
  283. address command 'copy 'newobj' to ram:obj'
  284.  
  285. displayrexxptr on
  286.  
  287. addaxis
  288. pick select
  289. getattributes
  290. axisName = ATTRIB.OBJECTNAME
  291.  
  292. transform_position AXIS_POSITION_X  AXIS_POSITION_Y  AXIS_POSITION_Z
  293. transform_alignment AXIS_ALIGNMENT_X AXIS_ALIGNMENT_Y AXIS_ALIGNMENT_Z
  294.  
  295. do i=1 to PNT_NUM
  296.  
  297.   loadobject "ram:obj"
  298.   pick select
  299.   address command 'wait sec 1'
  300.  
  301.   say PNT_X.i PNT_Y.i PNT_Z.i /* for some reason transform translate */
  302.                               /* does not like negative numbers      */
  303.  
  304.   transform_position trunc(PNT_X.i) trunc(PNT_Y.i) trunc(PNT_Z.i)
  305.  
  306.   getattributes
  307.   unpick
  308.   multipickon
  309.   pick axisName
  310.   pick ATTRIB.OBJECTNAME
  311.   multipickoff
  312.   group
  313.  
  314. end
  315.  
  316. address command 'delete ram:obj quiet'
  317.  
  318. displayrexxptr off
  319.  
  320. exit
  321. --- CUT ---
  322.  
  323. I tried using DISPLAYSTOPREDRAW throughout this script, but I wasn't
  324. able to totally eliminate the redraws. It saved some time, but there's
  325. still a step which is redrawing the display I can't seem to get rid of.
  326.  
  327. ---------------------------------
  328.  
  329. Date:         Tue, 13 Jan 1998 18:49:12 -0500
  330. From: "Ash R. J. Wyllie" <ashw@LR.NET>
  331.  
  332. >This is really cool! Thanks so much, Ash! (Is the 'trunc' statement a
  333. >general ARexx modifier? Just goes to show how little I'd have been able
  334. >to do in this regard myself...)
  335.  
  336. trunc() is one of the built in functions. If you wish to become a programmer
  337. you should do two things. 1) See a shrink. Maybe he can talk you out of this
  338. insane notion. If that doesn't work. 2) sit down and read the Arexx manual and
  339. the documentation for the various #?rexx#?.libraries that are on aminet. Try
  340. to remember all the fns, and what they do. 3) go back to the shrink (if you
  341. can find the time... :)).
  342.  
  343. ---------------------------------
  344.  
  345. Date:         Sat, 17 Jan 1998 00:59:16 EST
  346. From: AOLTechJOE <AOLTechJOE@AOL.COM>
  347.  
  348. In a message dated 98-01-16 23:39:35 EST, you write:
  349.  
  350. > All right, Chuck, where's your page?  (I was all set to fly there and
  351. >  scarf down everything,--but there was no url on your note).
  352.  
  353. Oops, sorry, I am so used to using YAM at home that sometimes I don't add my
  354. sig when using AOL at work.
  355. http://www.azstarnet.com/~midian
  356. Nothing for Imagine yet (still learning the commands and updating the
  357. Imagine.guide from 3.0 to 5.0)
  358.  
  359. Imagine Render contest - http://www.azstarnet.com/~midian/Imagine/
  360.  
  361. ---------------------------------
  362.  
  363. Date:         Sat, 17 Jan 1998 15:39:23 -0800
  364. From: Mike McCool <mikemcoo@EFN.ORG>
  365.  
  366. On Sat, 17 Jan 1998, AOLTechJOE wrote:
  367.  
  368. > Back on topic, how does the finished script look?  Is it available on
  369. > Aminet/web page?
  370.  
  371. Richard Mattsson posted the script back here a couple' days ago, with all
  372. the discussed changes/additions.  Ain't had a chance to try it yet, but I
  373. did d'load it.
  374.  
  375. Lemme know if you can't find it (since I know you must archive ALL iml
  376. posts) and I'll forward it to you.
  377.  
  378. (Oh and btw, thanks, Chuck, for re-posting your website, so we can all
  379. come and share your rexx scripts).
  380.  
  381.    http://www.efn.org/~mikemcoo
  382.    http://www.geocities.com/SoHo/lofts/9794
  383.